#include "getStatus.h"
#include "Arduino.h"
#include <HardwareSerial.h>
#include "bsp_motor.h"
#include "bsp_Graysensor.h"

float min_percent[4] = {FRONT_MIN,BEHIND_MIN,LEFT_MIN,RIGHT_MIN};
float limit_percent[4] = {FRONT_LIM_PERCENT,BEHIND_LIM_PERCENT,LEFT_LIM_PERCENT,RIGHT_LIM_PERCENT};
/**
 * @brief 判断灰度传感器是否检测到边界    是返回1 否返回0
 * @param void
 * @return uint8_t
 * */
uint8_t isConfine_Gray()
{
    float status[4];                       
    uint8_t result = 0b1111;                

    getGray(status, 0b1111);                //得到4个灰度传感器的值

    for (int i = 0; i < 4; i++)
    {
        result = (status[i] <= (min_percent[i] *limit_percent[i]) ) | (result << 1);        //比较灰度传感器的百分比值 判断是否出界
    }
   
    result = ~result;               //结果取反使是返回1 否返回0
    
    return result;
}
